package com.wjb.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wjb.pojo.entity.Coupon;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;

/**
 * @author : 王济彬
 * @date: 2025/5/25 - 05 - 25 - 0:21
 * @Description: com.wjb.mapper
 * @version: 1.0
 */
@Mapper
public interface CouponMapper extends BaseMapper<Coupon> {
    @Insert("insert into coupon (coupon_id,is_use,end_time,designated_good_id,id) values(#{couponId},#{isUse},#{endTime},#{designatedGoodId},#{id})")
    public boolean insertCoupon(int couponId, String isUse, Date endTime, int designatedGoodId, String id);

    @Select("select count(1) from coupon where coupon_id in ( #{couponId} )")
    public int hasCoupon(int couponid);

    @Update("update coupon set is_use =1 where coupon_id = #{id}")
    public boolean useCoupon(int id);

    @Select("select is_use from coupon where coupon_id = #{id}")
    public String getCouponIsUse(int id);
}
